package com.scau402.constants;

import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.stereotype.Component;

/**
 * Redis操作常量
 */
public class RedisConstants {
    public final static String INBOUND_PREFIX = "inbound:";
    public static final String OUTBOUND_PREFIX = "outbound:";
    public static final String DUP_KEY = "duplicate:";

    /**
     * src/main/resources/duplicate.lua，
     * Redis调用参数：KEYS数组为空， 前缀， 键， 时间(ms)
     */
    public static final DefaultRedisScript<Long> DUPLICATE_SCRIPT;
    static {
        DUPLICATE_SCRIPT = new DefaultRedisScript<>();
        DUPLICATE_SCRIPT.setLocation(new ClassPathResource("duplicate.lua"));
        DUPLICATE_SCRIPT.setResultType(Long.class);
    }
}
